#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
const int N=1e5+10;
ll d[N],v[N],a[N],p[N];
vector<bool>f[N];
ll n,m,L,V;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    ll t;
    cin>>t;
    while(t--){
        memset(f,0,sizeof(f));
        cin>>n>>m>>L>>V;
        ll cnt=0;
        for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++)cin>>p[i];
        for(int i=1;i<=n;i++){
            bool flag=0;
            for(int j=1;j<=m;j++){
                if(a[i]==0){
                    if(v[i]>V){
                        f[j].push_back(i);
                        flag=1;
                    }

                    continue;
                }
                if(p[j]-d[i]>=0){
                    if(sqrt(1.0*pow(v[i],2)+2.0*a[i]*(p[j]-d[i]))>V){
                        f[j].push_back(i);
                        flag=1;
                    }
                }
            }
            if(flag==1){
                cnt++;
            }
        }
        cout<<cnt<<' '<<m-2;
    }

    return 0;
}
